//
//  PopExplainView.m
//  safeLady
//
//  Created by Justsoso on 2017/7/18.
//  Copyright © 2017年 xmy. All rights reserved.
//

#import "PopExplainView.h"

@interface PopExplainView()

@property (nonatomic, strong) UIView *popView;
@property (nonatomic, strong) UIButton *closeButton;
@property (nonatomic, strong) UILabel *titleLabel;


@end

@implementation PopExplainView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
//        toolbar.barStyle = UIBarStyleDefault;
//        [self addSubview:toolbar];
        self.backgroundColor = [UIColor colorWithHex:0xE6E7E6 alpha:0.5];
        
        /* 弹出视图 */
        self.popView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth/2-W(135), ScreenHeight/2-H(164), W(270), H(328))];
        self.popView.backgroundColor = [UIColor colorWithHex:0xFFFFFF];
        [self addSubview:self.popView];

        self.popView.cornerRadius = 20;
        self.popView.shadowColor = [UIColor lightGrayColor];
        self.popView.shadowOffset = CGSizeMake(0, 2);
        self.popView.shadowRadius = 4;
        self.popView.shadowOpacity = 0.9;
        
        /* 取消弹出按钮 */
        self.closeButton = [[UIButton alloc] init];
        [self.closeButton setBackgroundImage:[UIImage imageNamed:@"x"] forState:UIControlStateNormal];
        [self.popView addSubview:self.closeButton];
        [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.popView.mas_top).offset(25);
            make.right.equalTo(self.popView.mas_right).offset(-25);
            make.width.height.equalTo(@(W(15)));
        }];
        
        /* 取消按钮点击时间 */
        [self.closeButton addTarget:self action:@selector(closePopView) forControlEvents:UIControlEventTouchUpInside];
        
        /* 标题 */
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.text = @"私处收缩";
        self.titleLabel.font = [UIFont systemFontOfSize:18.f];
        self.titleLabel.textColor = [UIColor colorWithHex:0x292529 alpha:1];
        [self.popView addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.popView.mas_left).offset(25);
            make.bottom.equalTo(self.closeButton.mas_bottom);
            make.height.equalTo(@18);
        }];
        
        /* 横线 */
        UILabel *line = [[UILabel alloc] init];
        line.backgroundColor = [UIColor colorWithHex:0xf7f7f7];
        [self.popView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.closeButton.mas_bottom).offset(25);
            make.left.equalTo(self.titleLabel.mas_left);
            make.right.equalTo(self.closeButton.mas_right);
            make.height.equalTo(@1);
        }];
        
        
        
    }
    return self;
}

- (void)closePopView {
    if (_dismissBlock) {
        _dismissBlock(self);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
